package com.yc.navy.blog.blog.service.Impl;

import com.yc.navy.blog.blog.bean.ArticleInfo;
import com.yc.navy.blog.blog.bean.ArticleInfoDTO;
import com.yc.navy.blog.blog.mapper.ArticleInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Company 海康信息
 * @author navy
 * @date 2024/9/6
 * Email haijunzhou@hikvision.com.cn
 */

@Service
public class ArticleInfoServiceImpl implements ArticleInfoService {

    @Autowired
    private ArticleInfoMapper articleInfoMapper;

    @Override
    public int add(ArticleInfo af) {
        if (StringUtil.checkNull(af.getTitle(), af.getContent(), af.getPic(), af.getTno())) {
            return -100;
        }
        return articleInfoMapper.add(af);
    }

    public List<ArticleInfoDTO> list(Integer page, Integer rows) {
        Map<String, Object> map = new HashMap<>();
        map.put("page", (page - 1) * rows);
        map.put("rows", rows);
        return articleInfoMapper.list(map);
    }

    @Override
    public ArticleInfoDTO find(Long ano) {
        return articleInfoMapper.find(ano);
    }
}
